const express = require('express');
const router = express.Router();

// 获取订单分类网格数据
router.post('/sortGridData', (req, res) => {
  try {
    const data = [{
      title: '手机保卖',
      img: '/static/images/home/goods/1.png'
    },{
      title: '数码保卖',
      img: '/static/images/home/goods/2.png'
    },{
      title: '欢乐送',
      img: '/static/images/home/goods/3.png'
    },{
      title: '美妆鉴别',
      img: '/static/images/home/goods/4.png'
    },{
      title: '采货节',
      img: '/static/images/home/goods/5.png'
    },{
      title: '图书特惠',
      img: '/static/images/home/goods/6.png'
    },{
      title: '家电回收',
      img: '/static/images/home/goods/7.png'
    },{
      title: '服饰清仓',
      img: '/static/images/home/goods/8.png'
    }];
    
    res.json({
      code: 200,
      message: 'success',
      data: data
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取订单导航列表数据
router.post('/navListData', (req, res) => {
  try {
    const data = ['全部','待付款','待发货','待收货','待评价','退款/售后'];
    
    res.json({
      code: 200,
      message: 'success',
      data: data
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取订单列表数据
router.post('/orderListData', (req, res) => {
  try {
    const data = [{
      order_id: 'DD20231215001',
      img: '/static/images/avatar/1.jpg',
      name: '仔仔数码旗舰店',
      status: '交易成功',
      price: "2238.00",
      num: 2,
      type: 1,
      create_time: '2023-12-15 14:30:25',
      goods_list: [{
        img: '/static/images/home/goods/1.png',
        name: '百度网盘云盘租号在线极速发货',
        introduce: '月租会员服务，支持多设备登录',
        tag: ['官方授权','自动续费'],
        price: "1.00",
        quantity: 1
      },{
        img: '/static/images/home/goods/2.png',
        name: '苹果iPhone X 256G 无锁99新',
        introduce: '原装正品，支持验机，7天无理由退货',
        tag: ['支持验机','专业质检','全国联保'],
        price: "2237.00",
        quantity: 1
      }]
    },{
      order_id: 'DD20231214002',
      img: '/static/images/avatar/2.jpg',
      name: '仔仔科技运营部',
      status: '交易关闭',
      price: "2199.00",
      num: 1,
      type: 0,
      create_time: '2023-12-14 10:15:42',
      goods_list: [{
        img: '/static/images/home/goods/3.png',
        name: 'MacBook Pro 13英寸 M1芯片 8+256G',
        introduce: '2020款，95新，原装充电器，全国联保',
        tag: ['支持验机','专业质检','官方认证'],
        price: "2199.00",
        quantity: 1
      }]
    },{
      order_id: 'DD20231213003',
      img: '/static/images/avatar/3.jpg',
      name: '时尚服饰专营店',
      status: '待发货',
      price: "358.00",
      num: 3,
      type: 1,
      create_time: '2023-12-13 16:20:18',
      goods_list: [{
        img: '/static/images/home/goods/4.png',
        name: '冬季加厚羽绒服男款中长款',
        introduce: '90%白鸭绒填充，防风防水面料',
        tag: ['正品保证','七天退换'],
        price: "299.00",
        quantity: 1
      },{
        img: '/static/images/home/goods/5.png',
        name: '休闲运动裤男款冬季加绒',
        introduce: '弹性面料，舒适保暖，多色可选',
        tag: ['新品上市','限时特惠'],
        price: "59.00",
        quantity: 1
      }]
    },{
      order_id: 'DD20231212004',
      img: '/static/images/avatar/4.jpg',
      name: '家电维修服务中心',
      status: '待收货',
      price: "128.00",
      num: 1,
      type: 0,
      create_time: '2023-12-12 09:45:33',
      goods_list: [{
        img: '/static/images/home/goods/6.png',
        name: '智能电饭煲3L容量多功能',
        introduce: '智能预约，24小时保温，易清洗内胆',
        tag: ['品牌直营','全国联保'],
        price: "128.00",
        quantity: 1
      }]
    },{
      order_id: 'DD20231211005',
      img: '/static/images/avatar/5.jpg',
      name: '图书音像专卖',
      status: '待评价',
      price: "156.50",
      num: 2,
      type: 1,
      create_time: '2023-12-11 14:10:27',
      goods_list: [{
        img: '/static/images/home/goods/7.png',
        name: 'JavaScript高级程序设计第4版',
        introduce: '人民邮电出版社，全新正版，包邮',
        tag: ['正版图书','包邮'],
        price: "89.50",
        quantity: 1
      },{
        img: '/static/images/home/goods/8.png',
        name: 'Python编程从入门到实践',
        introduce: '机械工业出版社，附带源码光盘',
        tag: ['畅销书籍','附赠资料'],
        price: "67.00",
        quantity: 1
      }]
    }];
    
    res.json({
      code: 200,
      message: 'success',
      data: data
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

module.exports = router;